package org.cttic.visualization.visualization.controller;

import org.cttic.visualization.visualization.common.AssistChargingRequest;
import org.cttic.visualization.visualization.util.ResponseObject;
import org.cttic.visualization.visualization.z_service.AssistChargingTimeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 2.6.2	辅助计费分时段统计查询
 */

@RestController
@CrossOrigin
public class AssistChargingController {

    @Autowired
    private AssistChargingTimeService assistChargingService;



    @RequestMapping("/api/assist/Charging")
    public ResponseObject assistCharging(@Valid @RequestBody AssistChargingRequest request, BindingResult binding){
        if(binding.hasErrors()){
            return ResponseObject.error(binding.getFieldError().getDefaultMessage());
        }

        return assistChargingService.assistCharging(request);
    }

}
